import numpy as np
from keras import Sequential
from keras.src.layers import Dense
from tensorflow.keras import Sequential


def test():
    #
    model = Sequential([Dense(units=1, input_shape=[1])])
    model.compile(optimizer='sgd', loss='mean_squared_error')
    # y=2x-1
    xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)
    ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)
    #
    model.fit(xs, ys, epochs=2000)
    print(model.predict(np.array([20], dtype=float)))


if __name__ == '__main__':
    test()
